package com.hysf.project1;


import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;

public class AppTest {
	public static void main(String[] args) {
		ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
//		PersonBiz personBiz = context.getBean(PersonBiz.class);
//		personBiz.addPerson(new Person(3, "hysf"));
//		Enhancer enhancer = new Enhancer();
//		enhancer.setSuperclass(PersonBiz.class);
//		enhancer.setCallback((MethodInterceptor)(obj, method, argss, proxy) -> {
//			if (!method.getName().equals("addPerson")) {
//				System.out.println("权限验证");
//				method.invoke(personBiz, argss);
//			} else {
//
//			}
//			return null;
//		});
//		PersonBiz target = (PersonBiz) enhancer.create();
//		target.findAll();
		
		String[] beanDefinitions = context.getBeanDefinitionNames();
		for (String beanDefinition : beanDefinitions) {
			System.out.println(beanDefinition);
		}
	}
}
